#include <opencv2\core\core.hpp>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\imgproc\imgproc.hpp>
#include <iostream>



using namespace std;  
using namespace cv; 


Mat blendImage(Mat input,Mat input2, double alpha = 0.5);

int main(){
	Mat img1 = imread("C:\\openCVImgs\\motor.jpg");
	Mat img2 = imread("C:\\openCVImgs\\imgm.bmp");

	if(!img1.data){
		cout << "error while loadin img1";
		getchar();
		return -1;
	}
	if(!img2.data){
		cout << "error while loadin img2";
		getchar();
		return -1;
	}

	/*
	Mat m = blendImage(img1,img2);
	namedWindow("blendedImage");
	imshow("blendedImage",m);
	*/

	double alpha = 0;
	namedWindow("blendedImage");
	while((alpha+=0.01) < 1.0){
		
		imshow("blendedImage",blendImage(img1,img2, alpha));
		waitKey(100);
	}
	waitKey(0);

	return 0;
}


Mat blendImage(Mat input1, Mat input2,  double alpha){
	Mat result;
	addWeighted(input1, alpha, input2, 1.0-alpha, 0.0, result);
	return result;
}